package v1

import (
	"ginblog/middleware"
	"ginblog/model"
	"ginblog/utils/errmsg"
	"github.com/gin-gonic/gin"
)

func Login(c *gin.Context) {
	var data model.User
	c.ShouldBindJSON(&data)
	token := ""
	code := model.CheckLogin(data.Username, data.Password)

	// 登陆成功
	if code == errmsg.SUCESS {
		token, _ = middleware.SetToken(data.Username)
	}
	Response(c, code, token)
}
